using System;
using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities
{
    /// <summary>
    /// 安全日志实体
    /// 用于记录系统安全相关的操作日志和事件
    /// </summary>
    public class SecurityLog : ITenantEntity
    {
        /// <summary>
        /// 安全日志标识符
        /// </summary>
        public long Id { get; set; }
        
        /// <summary>
        /// 跟踪标识符
        /// 用于关联同一次请求的多个日志记录
        /// </summary>
        public string? TraceId { get; set; }
        
        /// <summary>
        /// 日志级别
        /// 如：Debug、Info、Warning、Error、Critical
        /// </summary>
        public string? LogLevel { get; set; }
        
        /// <summary>
        /// 日志消息
        /// 安全操作的具体描述信息
        /// </summary>
        public string? Message { get; set; }
        
        /// <summary>
        /// 时间戳
        /// 安全事件发生的精确时间
        /// </summary>
        public DateTime Timestamp { get; set; }
        
        /// <summary>
        /// 用户标识符
        /// 执行操作的用户ID
        /// </summary>
        public string? UserId { get; set; }
        
        /// <summary>
        /// 请求路径
        /// HTTP请求的路径信息
        /// </summary>
        public string? RequestPath { get; set; }
        
        /// <summary>
        /// 异常信息
        /// 如果操作发生异常，记录异常的详细信息
        /// </summary>
        public string? Exception { get; set; }
        
        /// <summary>
        /// 额外数据
        /// 以JSON格式存储的其他相关安全信息
        /// </summary>
        public string? ExtraData { get; set; }

        /// <summary>
        /// HTTP方法
        /// 如：GET、POST、PUT、DELETE
        /// </summary>
        public string? HttpMethod { get; set; }

        /// <summary>
        /// 状态码
        /// HTTP响应状态码
        /// </summary>
        public int? StatusCode { get; set; }

        /// <summary>
        /// IP地址
        /// 客户端的IP地址
        /// </summary>
        public string? IpAddress { get; set; }

        /// <summary>
        /// 用户代理
        /// 客户端的用户代理字符串
        /// </summary>
        public string? UserAgent { get; set; }

        /// <summary>
        /// 安全事件类型
        /// 如：登录失败、权限违规、恶意请求等
        /// </summary>
        public string? SecurityEventType { get; set; }

        /// <summary>
        /// 威胁级别
        /// 如：Low、Medium、High、Critical
        /// </summary>
        public string? ThreatLevel { get; set; }

        /// <summary>
        /// 攻击类型
        /// 如：SQL注入、XSS、CSRF等
        /// </summary>
        public string? AttackType { get; set; }

        /// <summary>
        /// 是否被阻止
        /// 标记威胁是否被成功阻止
        /// </summary>
        public bool? IsBlocked { get; set; }

        /// <summary>
        /// 阻止原因
        /// 为什么阻止该请求
        /// </summary>
        public string? BlockReason { get; set; }

        /// <summary>
        /// 风险评分
        /// 0-100的风险评分
        /// </summary>
        public int? RiskScore { get; set; }

        /// <summary>
        /// 地理位置信息
        /// 客户端的地理位置信息
        /// </summary>
        public string? GeolocationInfo { get; set; }

        /// <summary>
        /// 设备信息
        /// 客户端设备的相关信息
        /// </summary>
        public string? DeviceInfo { get; set; }

        /// <summary>
        /// 租户ID
        /// 多租户环境下的租户标识
        /// </summary>
        public string TenantId { get; set; } = string.Empty;

        /// <summary>
        /// 关联ID
        /// 分布式环境下的请求关联标识
        /// </summary>
        public string? CorrelationId { get; set; }

        /// <summary>
        /// 附加数据
        /// 其他相关的安全上下文信息
        /// </summary>
        public string? AdditionalData { get; set; }

        /// <summary>
        /// 创建时间
        /// 安全事件创建的时间
        /// </summary>
        public DateTime? CreatedAt { get; set; } = DateTime.UtcNow;
    }
}
